﻿module core.hgeclass;

private import core.hge;
private import core.dll;



extern (Windows){
	

interface IUnknown{		//必须使用名为 IUnknown 的接口才能使D语言正确使用C++接口,为了达到此目的,这里屏蔽了D标准库中的 IUnknown定义而自行定义了一个空接口
}
interface ifHge: IUnknown
	{
	 void			Release();		
	
	 bool			System_Initiate();
	 void			System_Shutdown();
	 bool			System_Start();
	 char*			System_GetErrorMessage();
	void			System_Log(char *format, ...);
	 bool			System_Launch(char *url);
	 void			System_Snapshot(char *filename= null);

	 void			System_SetStateBool  (hgeBoolState   state, bool        value);
	 void			System_SetStateFunc  (hgeFuncState   state, hgeCallback value);
	 void			System_SetStateHwnd  (hgeHwndState   state, HWND        value);
	 void			System_SetStateInt   (hgeIntState    state, int         value);
	 void			System_SetStateString(hgeStringState state, char *value);
	 bool			System_GetStateBool  (hgeBoolState   state);
	 hgeCallback	System_GetStateFunc  (hgeFuncState   state);
	 HWND			System_GetStateHwnd  (hgeHwndState   state);
	 int			System_GetStateInt   (hgeIntState    state);
	 char*		 	System_GetStateString(hgeStringState state);

	 void*			Resource_Load(char *filename, uint *size=null);
	 void			Resource_Free(void *res);
	 bool			Resource_AttachPack(char *filename, char *password=null);
	 void			Resource_RemovePack(char *filename);
	 void			Resource_RemoveAllPacks();
	 char*			Resource_MakePath(char *filename);
	 char*			Resource_EnumFiles(char *wildcard=null);
	 char*			Resource_EnumFolders(char *wildcard=null);

	void			Ini_SetInt(char *section, char *name, int value);
	int				Ini_GetInt(char *section, char *name, int def_val);
	void			Ini_SetFloat(char *section, char *name, float value);
	float			Ini_GetFloat(char *section, char *name, float def_val);
	void			Ini_SetString(char *section, char *name, char *value);
	char*			Ini_GetString(char *section, char *name, char *def_val);

	 void			Random_Seed(int seed=0);
	 int			Random_Int(int min, int max);
	 float			Random_Float(float min, float max);

	 float			Timer_GetTime();
	 float			Timer_GetDelta();
	 int			Timer_GetFPS();

	 HEFFECT		Effect_Load(char *filename, uint size=0);
	 void			Effect_Free(HEFFECT eff);
	 HCHANNEL	 	Effect_Play(HEFFECT eff);
	 HCHANNEL		Effect_PlayEx(HEFFECT eff, int volume=100, int pan=0, float pitch=1.0f, bool loop=false);

	 HMUSIC			Music_Load(char *filename, uint size=0);
	 void			Music_Free(HMUSIC mus);
	 HCHANNEL		Music_Play(HMUSIC mus, bool loop);

	 HSTREAM		Stream_Load(char *filename, uint size=0);
	 void			Stream_Free(HSTREAM stream);
	 HCHANNEL		Stream_Play(HSTREAM stream, bool loop, int volume = 100);

	 void			Channel_SetPanning(HCHANNEL chn, int pan);
	 void		 	Channel_SetVolume(HCHANNEL chn, int volume);
	 void		 	Channel_SetPitch(HCHANNEL chn, float pitch);
	 void		 	Channel_Pause(HCHANNEL chn);
	 void		 	Channel_Resume(HCHANNEL chn);
	 void		 	Channel_Stop(HCHANNEL chn);
	 void		 	Channel_StopAll();
	 bool			Channel_IsPlaying(HCHANNEL chn);
	 float			Channel_GetLength(HCHANNEL chn);
	 float			Channel_GetPos(HCHANNEL chn);
	 void			Channel_SetPos(HCHANNEL chn, float fSeconds);

	 void			Input_GetMousePos(float *x, float *y);
	 void			Input_SetMousePos(float x, float y);
	 int			Input_GetMouseWheel();
	 bool			Input_IsMouseOver();
	 bool			Input_GetKeyState(int key);
	 char*			Input_GetKeyName(int key);
	 int			Input_GetKey();
	 int			Input_GetChar();
	 bool			Input_GetEvent(hgeInputEvent *event);

	 bool			Gfx_BeginScene(HTARGET target=0);
	 void			Gfx_EndScene();
	 void			Gfx_Clear(uint color);
	 void			Gfx_RenderLine(float x1, float y1, float x2, float y2, uint color=0xFFFFFFFF, float z=0.5f);
	 void			Gfx_RenderTriple(hgeTriple triple);
	 void			Gfx_RenderQuad(hgeQuad* quad);
	 hgeVertex*		Gfx_StartBatch(int prim_type, HTEXTURE tex, int blend, int *max_prim);
	 void			Gfx_FinishBatch(int nprim);
	 void			Gfx_SetClipping(int x=0, int y=0, int w=0, int h=0);
	 void			Gfx_SetTransform(float x=0, float y=0, float dx=0, float dy=0, float rot=0, float hscale=0, float vscale=0); 

	 HTARGET		Target_Create(int width, int height, bool zbuffer);
	 void			Target_Free(HTARGET target);
	 HTEXTURE		Target_GetTexture(HTARGET target);

	 HTEXTURE		Texture_Create(int width, int height);
	 HTEXTURE		Texture_Load(char *filename, uint size=0, bool bMipmap=false);
	 void			Texture_Free(HTEXTURE tex);
	 int			Texture_GetWidth(HTEXTURE tex, bool bOriginal=false);
	 int			Texture_GetHeight(HTEXTURE tex, bool bOriginal=false);
	 uint*			Texture_Lock(HTEXTURE tex, bool bReadOnly=true, int left=0, int top=0, int width=0, int height=0);
	 void			Texture_Unlock(HTEXTURE tex);
	}
}


DllImport!(r"res\hge.dll", "hgeCreate", ifHge function(int))   hgeCreate ;

